<template>
  <div :class="$style.bluemodal">
    <div :class="$style.topBlock">
      <div :class="$style.tabBox">
        <div :class="[$style.tabItem, tabIndex == 0 ? $style.tabActive : '']" @click="changeTab(0)">银行卡</div>
        <div :class="[$style.tabItem, tabIndex == 1 ? $style.tabActive : '']" @click="changeTab(1)">钱包</div>
      </div>
      <div :class="$style.btnBox">
        <lay-button type="normal" @click="addFn">{{ tabIndex == 0 ? '添加银行卡' : '添加钱包' }}</lay-button>
      </div>
    </div>
    <div :class="$style.mainBlock">
      <template v-if="tabIndex == 0">
        <div :class="$style.cardItem" v-for="(item, index) in bankList" :key="index">
          <div :class="$style.cardTop">
            <div :class="$style.cardTitle">{{ item.name }}</div>
            <img :class="$style.cardIcon" src="/shanchubai.png" alt="" @click="delBank(index)" />
          </div>
          <div :class="$style.cardBottom">
            {{ item.content }}
          </div>
        </div>
      </template>
      <template v-else>
        <div :class="$style.cardItem" v-for="(item, index) in walletList" :key="index">
          <div :class="$style.cardTop">
            <div :class="$style.cardTitle">{{ item.name }}</div>
            <img :class="$style.cardIcon" src="/shanchubai.png" alt="" @click="delWallet(index)" />
          </div>
          <div :class="$style.cardBottom">
            {{ item.content }}
          </div>
        </div>
      </template>
    </div>
  </div>
</template>
<script>
import { defineComponent } from "vue";
export default defineComponent({
  name: "BlueModal",
  data() {
    return {
      tabIndex: 0,
      bankList: [
        { name: '中国农业银行', content: '***************5623' },
        { name: '中国银行', content: '***************5623' },
        { name: '中国建设银行', content: '***************5623' },
      ],
      walletList: [
        { name: 'USDT', content: '***************5623' },
        { name: 'USDT', content: '***************5623' },
        { name: 'USDT', content: '***************5623' },
      ],
    };
  },
  methods: {
    delWallet(index) {

    },
    delBank(index) {

    },
    addFn(){
      this.$emit('addCard',this.tabIndex);
    },
    changeTab(index) {
      this.tabIndex = index;
    },
  },
});
</script>
<style module>
.bluemodal {
  width: 100%;
  height: 100%;
  box-sizing: border-box;
  padding-right: 20px;
}

.topBlock {
  width: 100%;
  height: 135px;
  box-sizing: border-box;
  border-bottom: 1px solid #DCDFE6;
  padding: 25px 0 0 20px;
}

.tabBox {
  width: 100%;
  height: 40px;
  background: #F0F2F5;
  border-radius: 3px;
  display: flex;
  align-items: center;
  box-sizing: border-box;
  padding: 5px;
  margin-bottom: 17px;
}

.tabItem {
  width: 50%;
  height: 100%;
  text-align: center;
  line-height: 30px;
  font-family: Source Han Sans;
  font-size: 14px;
  font-weight: 300;
  color: #515A6E;
  cursor: pointer;
}

.tabActive {
  background-color: #FFFFFF;
  border-radius: 3px;
  color: #1890FF;
}

.btnBox {
  width: 100%;
  text-align: right;
}

.mainBlock {
  width: 100%;
  max-height: calc(100% - 135px);
  box-sizing: border-box;
  padding: 32px 0 20px 20px;
  display: flex;
  flex-wrap: wrap;
  overflow-y: auto;
}

.cardItem {
  width: calc((100% - 20px) / 2);
  border-radius: 10px;
  background: linear-gradient(90deg, #1890FF 0%, #1144CE 100%);
  margin-bottom: 20px;
  margin-left: 20px;
}

.cardItem:nth-child(odd) {
  margin-left: 0;
}

.cardTop {
  width: 100%;
  height: 45px;
  box-sizing: border-box;
  border-bottom: 5px solid #FFFFFF;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.cardTitle {
  font-family: Source Han Sans;
  font-size: 14px;
  font-weight: 300;
  color: #FFFFFF;
}

.cardIcon {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.cardBottom {
  width: 100%;
  box-sizing: border-box;
  padding: 33px 20px 40px 20px;
  font-family: Source Han Sans;
  font-size: 14px;
  font-weight: 500;
  color: #FFFFFF;
}
</style>
<style scoped>
.layui-btn {
  width: 102px;
  height: 32px;
  line-height: 32px;
}
</style>